package com.ohuang.hook.http

import android.content.Context
import android.util.Log
import com.google.gson.Gson
import com.ohuang.hook.heihe.Heihe

import com.ohuang.kthttp.HttpClient
import com.ohuang.kthttp.HttpRequest
import com.ohuang.kthttp.call.HttpCall
import com.ohuang.kthttp.call.getResult
import com.ohuang.kthttp.call.map
import com.ohuang.kthttp.post
import com.ohuang.kthttp.transform.transForm
import com.ohuang.kthttp.urlParams
import kotlinx.coroutines.runBlocking
import java.io.UnsupportedEncodingException
import java.net.URLEncoder

object testApi {
    var mHttpClient = HttpClient()
    var gson = Gson()



    /**
     * 编码
     * urlEncode
     */
    private fun String.urlEncode(): String {
        try {
            return URLEncoder.encode(this, "utf-8")
        } catch (e: UnsupportedEncodingException) {
        }
        return this
    }

    /**
     * 解码
     * urlDecode
     */
    private fun String.urlDecode(): String {
        try {
            return java.net.URLDecoder.decode(this, "utf-8")
        } catch (e: UnsupportedEncodingException) {
        }
        return this
    }




    fun getGameInfo(context: Context): HttpCall<String> {


        return mHttpClient.stringCall {
            urlParams(
                "http://api.maxjia.com/game/get_game_detail/"
            ) {
                addAllParams(value)
                addParam("appid","2933080")

            }

            addHeader("Referer", "http://api.maxjia.com/")
            addHeader(
                "User-Agent",
                "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36 ApiMaxJia/1.0"
            )
//            addHeader(
//                "Cookie",
//                "pkey=MTczOTMyMTg2NS4xOV83NTk1ODkzMnpjZHB2bGR2eWh3Z29rYXU__;x_xhh_tokenid=BFfhcn5uBSnzCBak6DZmcLKsub/yLUqpEKuDXwgr7tSptIMtIC/LYd6SeVJHp8LJCD7b/z1kZg4dOHKWjf14prw=="
//            )
            addHeader("Host", "api.xiaoheihe.cn")
            addHeader("Connection", "Keep-Alive")
            addHeader("Accept-Encoding", "gzip")


        }
    }





}